﻿@using Models.DTO
@model IList<NoticeOutputDto>
@{
    ViewBag.Title = "网站公告栏";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="~/Assets/timeline.css" rel="stylesheet" />
<link href="~/Assets/UEditor/third-party/SyntaxHighlighter/styles/shCore.min.css" rel="stylesheet" />
<div class="container min-height780">
    <ol class="cd-breadcrumb triangle">
        <li>@Html.ActionLink("首页", "Index", "Home")</li>
        <li class="current"><em>@ViewBag.Title</em></li>
    </ol>
    @{
        Html.RenderPartial("_Pagination");
    }
    <a href="/dashboard#/notice/index" class="btn btn-info">发布新公告</a>
    <div class="row">
        <div class="col-md-12">
            <div class="main-timeline">
                @foreach(NoticeOutputDto n in Model) {
                    <div class="timeline">
                        <div class="timeline-content">
                            <div class="circle"><span><i class="fa fa-globe"></i></span>
                            </div>
                            <div class="content">
                                <span class="year">@n.PostDate.ToString("yyyy-MM-dd HH:mm:ss")</span>
                                <div class="title">
                                    <span>@n.Title</span>
                                    <div class="btn-group">
                                        <button class="btn btn-danger" onclick="del(@n.Id,'@n.Title')">删除</button>
                                        <a class="btn btn-info" href="/dashboard#/notice/index?id=@n.Id" target="_blank">修改</a>
                                    </div>
                                </div> 
                                <p class="description">
                                    <a href="/n/@n.Id" class="tippy-scale" title="查看详情">@MvcHtmlString.Create(n.Content)</a>
                                </p>
                                <div class="icon"><span></span>
                                </div>
                            </div>
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
    @{
        Html.RenderPartial("_Pagination");
    }
</div>
<script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/shCore.min.js"></script>
<script src="~/Assets/UEditor/third-party/SyntaxHighlighter/scripts/bundle.min.js"></script>
<script>
    SyntaxHighlighter.all();
    SyntaxHighlighter.defaults['toolbar'] = false;
	function del(id,title) {
        swal({
            title: "确认删除这条公告吗？",
            text: title,
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            showLoaderOnConfirm: true,
            animation: true,
            allowOutsideClick: false
        }).then(function () {
            $.post("/notice/delete", {
                id: id
            }, function (data) {
                window.notie.alert({
                    type: 1,
                    text: data.Message,
                    time: 4
                });
                window.location.reload();
            });
        }, function () {
        });
	}
</script>